home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE08 / DATADICT / OLDTMP.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-10-05  |  2.4 KB  |  69 lines

  1.   tempowner := tempclass.create(application);
  2.   with tempowner do begin
  3.     try
  4.       session.dropConnections;
  5.       table1 := ttable.create(tempowner);
  6.       Table1.DatabaseName:= DDAliasName;
  7.       Table1.TableType := ttDbase;
  8.       Table1.TableName:= DDTableName;
  9.       Table1.Active:= True;
  10.       dataSource1 := tdatasource.create(tempowner);
  11.       DataSource1.DataSet:= Table1;
  12.       query1 := tquery.create(tempowner);
  13.       query1.databasename := DDAliasName;
  14.       query1.datasource := DataSource1;
  15.       query1.close;
  16.       query1.sql.clear;
  17.       query1.params.clear;
  18.       sqlstr := 'SELECT * FROM '+DDTableName;
  19.       query1.sql.add(sqlstr);
  20.       query1.prepare;
  21.       query1.open;
  22.       query1.first;
  23.       { get tablenames in data dictionary, stick in tables stringlist}
  24.       if query1.findfield('TABLE_NAME') = nil
  25.         then begin
  26.            cursor := crDefault;
  27.            MessageDlg('Not a Data Dictionary Database.', mtInformation, [mbOK], 0);
  28.            m_status.hide;
  29.            tempowner.free;
  30.            {I presume the above closes database1 and query1?}
  31.            result := ExistButNotDD;
  32.            exit;
  33.            end;
  34.       m_tableList.lines.add(query1.findfield('TABLE_NAME').text);  {get first one}
  35.       inc(numfields);
  36.       query1.next;
  37.       while not query1.eof do begin
  38.         tablefound := false;
  39.         thistable := query1.findfield('TABLE_NAME').text;
  40.         inc(numFields);
  41.         for tablenum := 0 to m_tablelist.lines.count - 1 do
  42.           if m_tableList.lines[tablenum] = thistable
  43.              then begin
  44.                 tablefound := true;
  45.                 break;
  46.                 end;
  47.           {done looking for thistable}
  48.         if not tablefound
  49.           then  m_tablelist.lines.add(thistable);
  50.         query1.next;
  51.         end; {while searching for table names}
  52.     except
  53.        on EdataBaseError do begin
  54.          cursor := crDefault;
  55.          MessageDlg('Not a data base file or other DB error', mtInformation, [mbOK], 0);
  56.          l_size.caption := '';
  57.          l_update.caption := '';
  58.          m_status.hide;
  59.          result := ExistbutnotDD;
  60.          end;
  61.   end;  {with tempowner}
  62.   l_numtables.caption := intToSTr(m_tablelist.lines.count);
  63.   l_numfields.caption := IntToStr(numfields);
  64.   groupbox2.caption := 'Stats on '+DDtablename;
  65.   query1.close;
  66.   database1.close;
  67.   tempowner.free;
  68.   end;
  69.